package com.gp.node.operator;

import com.gp.node.INode;
import com.stock.StockData;

public class And extends IOperatorBinary {

	private static final long serialVersionUID = -6619882153589256699L;

	@Override
	public double getValue(StockData stock) {
		if ((right.getValue(stock) > 0) && (left.getValue(stock) > 0))
			return 1.0;
		else
			return 0.0; 
	}

	@Override
	public INode createNew()  {
		 return new And();
	}
	
	@Override
	public INode copy() {
		And node = new And();
		node.setByCopy(this);
		return node;
	}
	
	@Override
	public String print(StockData stock) {
		return "(" + right.print(stock) + ") && (" + left.print(stock) + ")";
	}
	
	@Override
	public String print() {
		return "(" + right.print() + ") && (" + left.print() + ")";
	}


}
